package com.shop.shoppingmall.controller;

import com.shop.shoppingmall.entity.TSku;
import com.shop.shoppingmall.service.TSkuService;
import com.shop.shoppingmall.service.TSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * (TSku)表控制层
 *
 * @author makejava
 * @since 2020-09-24 10:37:41
 */
@RestController
@RequestMapping("tSku")
public class TSkuController {
    /**
     * 服务对象
     */
    @Resource
    private TSkuService tSkuService;
    @Resource
    private TSpecService tSpecService;
    /*@Autowired
    private RedisTemplate<String,String> redisTemplate;*/

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TSku selectOne(Integer id) {
        return this.tSkuService.queryById(id);
    }


//    @PostMapping("getGoodsSpecList")
//    public Result getGoodsSpecList(String goodsId) {
//        return tSpecService.findAttrListByGoodsId(goodsId);
//    }

    /*@PostMapping("/test")
    public void test(@RequestBody Map map){
        String num = (String) map.get("num");
        String userId = (String) map.get("userId");
        ValueOperations<String, String> operations = redisTemplate.opsForValue();
        operations.set("orderNumber,"+num, userId);
        redisTemplate.expire("orderNumber,"+num, 10, TimeUnit.SECONDS);
        System.out.println("hualihushao");
    }*/
}
